package com.sh.common;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.util.List;

@Data
@Builder
@AllArgsConstructor
public class PageData<T> {

  private List<T> records;
  // 当前页
  private Integer pageNum;
  // 页面条数
  private Integer pageSize;

  // 总页数
  private Integer totalPages;
  // 总数据条数
  private Integer totalElements;

  public Integer getTotalPages() {
    if(totalPages==null){
      return  (totalElements + pageSize - 1) / pageSize;
    }
    return totalPages;
  }


}
